from PyQt5 import QtCore
from PyQt5.QtGui import QTextBlock
from PyQt5.QtWidgets import QWidget,QHBoxLayout,QLabel,QFrame,QSplitter,QLCDNumber,QPushButton
from PyQt5.QtCore import Qt
#from PyQt5.QtGui import *

class Demo_ui(QWidget):
    def initUI(self):
        #设置全局布局为水平布局，设置标题与初始大小窗口
        self.hbox = QHBoxLayout()
        self.setWindowTitle("抢答器")
        self.setGeometry(600,400,600,400)

        #实例化QLabel控件
        self.topLeft=QLabel()
        self.topLeft.setFrameShape(QFrame.StyledPanel)
        self.topLeft.setText("红队")
        self.topLeft.setAlignment(Qt.AlignCenter)
        self.topLeft.setStyleSheet("color:red")


        self.topRight=QLabel()
        self.topRight.setFrameShape(QFrame.StyledPanel)
        self.topRight.setText("蓝队")
        self.topRight.setAlignment(Qt.AlignCenter)
        self.topRight.setStyleSheet("color:blue")

        #实例化QSplitter控件并设置初始为水平方向布局
        self.Color=QSplitter(Qt.Horizontal)
        #向Splitter内添加控件。并设置游戏的初始大小
        self.Color.addWidget(self.topLeft)
        self.Color.addWidget(self.topRight)
        self.Color.setSizes([150,150])
        
        #实例化QSplitter控件并设置初始为水平方向布局
        self.timer_1 = QSplitter(Qt.Horizontal)
        self.downLeft = QLCDNumber()
        #self.downLeft.setAlignment(Qt.AlignCenter)
        self.downLeft.setDigitCount(6)

        
        self.downRight=QLCDNumber()
        self.downRight.setDigitCount(6)
        #self.downRight.setAlignment(Qt.AlignCenter)
        value = "10"
        self.downRight.display(value.center(6))
        self.downLeft.display(value.center(6))

        self.timer_1.addWidget(self.downLeft)
        self.timer_1.addWidget(self.downRight)
        self.timer_1.setSizes([150,150])

        self.btn_list = QSplitter(Qt.Horizontal)
        self.bnt_setup = QPushButton("设置")
        self.bnt_start = QPushButton("开始")
        self.bnt_stop = QPushButton("重置")
        
        #self.re_but.setText("开始")
        #self.re_but.sizeHint()
        self.btn_list.addWidget(self.bnt_setup)
        self.btn_list.addWidget(self.bnt_start)
        self.btn_list.addWidget(self.bnt_stop)



        #实例化Splitter管理器，添加控件到其中，设置垂直方向
        self.main_win=QSplitter(Qt.Vertical)
        self.main_win.addWidget(self.Color)
        self.main_win.addWidget(self.timer_1)
        self.main_win.addWidget(self.btn_list)
        self.main_win.setSizes([100,400,50])
        #设置窗体全局布局以及子布局的添加
        self.hbox.addWidget(self.main_win)
        self.setLayout(self.hbox)
        QtCore.QMetaObject.connectSlotsByName(self.hbox)

